﻿// ==================================================================================================
// Copyright(C) 2018 FI Ltd. All rights reserved.
//
// SYSTEM NAME	: FI.Net Application Framework
// COMPONENT ID	: FI.Core.ApplicationContexts
// COMPONENT DESC:		
//
// CREATED DATE/BY:		18 Aug 2018 / Tian Mi
//
// REVISION HISTORY:	
// DATE/BY			SR#/CS/PM#/OTHERS		DESCRIPTION OF CHANGE
// ==================================================================================================

using System;

namespace FI.Core.ApplicationContexts
{
    /// <summary>
    /// A entity with <see cref="DependentApplicationContext"/>.
    /// </summary>
    [Serializable]
    public class ContextAwareData<T>
    {
        [NonSerialized]
        private DependentApplicationContext context;

        /// <summary>
        /// Initializes a new instance of the <see cref="ContextAwareData{T}"/> class.
        /// </summary>
        /// <param name="data">The data.</param>
        public ContextAwareData(T data)
        {
            this.context = ApplicationContext.Current.DependentClone();
            this.Data = data;
        }

        /// <summary>
        /// Gets the application context.
        /// </summary>
        public DependentApplicationContext Context
        {
            get { return this.context; }
        }

        /// <summary>
        /// Gets or sets the data.
        /// </summary>
        public T Data { get; set; }
    }
}